import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: 'Example', icon: 'example' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      }
    ]
  },

  /* 图形识别路由 */
  {
    path: '/animal_recogniton',
    component: Layout,
    redirect: '/animal_recogniton/index',
    name: '图像识别接口',
    meta: { title: '图像识别', icon: 'basePriviliage' },
    children: [
      {
        path: 'animal_recogniton',
        name: 'animal_recogniton',
        component: () => import('@/views/AnimalRecognition/index'),
        meta: { title: '图像识别接口', icon: 'table' }
      },
      

    ]
  },

  /* 冯琼华路由管理 */
  {
    path: '/fqh',
    component: Layout,
    redirect: '/fqh/list',
    name: '冯琼华',
    meta: { title: '冯琼华', icon: 'basePriviliage' },
    children: [
      {
        path: 'basePriviliage',
        name: 'basePriviliageList',
        component: () => import('@/views/BasePrivilege/List'),
        meta: { title: '数据库-特权', icon: 'table' }
      },
      {
        path: 'basePriviliage_Form',
        name: 'basePriviliage',
        component: () => import('@/views/BasePrivilege/Form'),
        hidden: true,
        meta: { title: '数据库-特权', icon: 'table' }
      },
      {
        path: 'BaseRole',
        name: 'BaseRoleList',
        component: () => import('@/views/BaseRole/List'),
        meta: { title: '数据库-用户', icon: 'table' }
      },
      {
        path: 'BaseRole_Form',
        name: 'BaseRoleList',
        component: () => import('@/views/BaseRole/Form'),
        hidden: true,
        meta: { title: '数据库-用户', icon: 'table' }
      },
      {
        path: 'RolePrivilege',
        name: 'RolePrivilegeList',
        component: () => import('@/views/RolePrivilege/List'),
        meta: { title: '用户特权', icon: 'table' }
      },
      {
        path: 'RolePrivilege_Form',
        name: 'RolePrivilegeList',
        component: () => import('@/views/RolePrivilege/Form'),
        hidden: true,
        meta: { title: '用户特权', icon: 'table' }
      },

    ]
  },


  /* 罗单丹：用户管理路由 */
  {
    path: '/ldd',
    component: Layout,
    redirect: '/ldd/list',
    name: '罗单丹',
    meta: { title: '罗单丹', icon: 'application' },
    children: [
      {
        path: 'application',
        name: 'applicationList',
        component: () => import('@/views/Application/List'),
        meta: { title: '应用管理', icon: 'table' }
      },
      {
        path: 'application_Form',
        name: 'applicationList',
        component: () => import('@/views/Application/Form'),
        hidden: true,
        meta: { title: '应用管理', icon: 'table' }
      },
      {
        path: 'Dataset',
        name: 'DatasetList',
        component: () => import('@/views/Dataset/List'),
        meta: { title: '数据集', icon: 'table' }
      },
      {
        path: 'Dataset_Form',
        name: 'DatasetList',
        hidden: true,
        component: () => import('@/views/Dataset/Form'),
        meta: { title: '数据集', icon: 'table' }
      },
      {
        path: 'Interface',
        name: 'InterfaceList',
        component: () => import('@/views/Interface/List'),
        meta: { title: '接口管理', icon: 'table' }
      },
      {
        path: 'Interface_Form',
        name: 'InterfaceList',
        hidden: true,
        component: () => import('@/views/Interface/Form'),
        meta: { title: '接口管理', icon: 'table' }
      }
    ]
  },


  /* 黎海梅路由管理 */
  {
    path: '/lhm',
    component: Layout,
    redirect: '/lhm/list',
    name: '黎海梅',
    meta: { title: '黎海梅', icon: 'BaseConfig' },
    children: [
      {
        path: 'BaseConfig',
        name: 'BaseConfigList',
        component: () => import('@/views/BaseConfig/List'),
        meta: { title: 'BaseConfig', icon: 'table' }
      },
      {
        hidden: true,
        path: 'BaseConfig_Form',
        name: 'BaseConfig_Form',
        component: () => import('@/views/BaseConfig/Form'),
        meta: { title: 'BaseConfig提交', icon: 'table' }
      },
      {
        path: 'BaseFile',
        name: 'BaseFileList',
        component: () => import('@/views/BaseFile/List'),
        meta: { title: 'BaseFile', icon: 'table' }
      },
      {
        hidden: true,
        path: 'BaseFile_Form',
        name: 'BaseFile_Form',
        component: () => import('@/views/BaseFile/Form'),
        meta: { title: 'BaseFile提交', icon: 'table' }
      },
      {
        path: 'BaseLog',
        name: 'BaseLogList',
        component: () => import('@/views/BaseLog/List'),
        meta: { title: '日志管理', icon: 'table' }
      },
      {
        hidden: true,
        path: 'BaseLog_Form',
        name: 'BaseLog_Form',
        component: () => import('@/views/BaseLog/Form'),
        meta: { title: 'BaseLog提交', icon: 'table' }
      },
    ]
  },
  /* 唐静梅路由管理 */
  //绿色大棚信息路由管理
  {
    path: '/tjm',
    component: Layout,
    redirect: '/tjm/list',
    name: '唐静梅',
    meta: { title: '唐静梅', icon: 'greenhouse_message' },
    children: [
      {
        path: 'greenhouse_message',
        name: 'greenhouse_message',
        component: () => import('@/views/greenhouse_message/List'),
        meta: { title: '绿色大棚信息', icon: 'table' }
      },
      {
        hidden: true,//隐藏
        path: 'greenhouse_message_Form',
        name: 'greenhouse_message_Form',
        component: () => import('@/views/greenhouse_message/Form'),
        meta: { title: '绿色大棚信息提交', icon: 'table' }
      },
      {
        path: 'recognition_call_log',
        name: 'recognition_call_log',
        component: () => import('@/views/recognition_call_log/List'),
        meta: { title: '识别', icon: 'table' }
      },
      {
        hidden: true,//隐藏
        path: 'recognition_call_log_Form',
        name: 'recognition_call_log_Form',
        component: () => import('@/views/recognition_call_log/Form'),
        meta: { title: '识别提交', icon: 'table' }
      },
      {
        path: 'greenhouse_module',
        name: 'greenhouse_module',
        component: () => import('@/views/greenhouse_module/List'),
        meta: { title: '温室大棚模型', icon: 'table' }
      },
      {
        hidden: true,//隐藏
        path: 'greenhouse_module_Form',
        name: 'greenhouse_module_Form',
        component: () => import('@/views/greenhouse_module/Form'),
        meta: { title: '温室大棚模型提交', icon: 'table' }
      },
    ]
  },

  /*谭锦锋路由管理*/
  {
    path: '/tjf',
    component: Layout,
    redirect: '/tjf/list',
    name: '谭锦锋',
    meta: { title: '谭锦锋', icon: 'category' },
    children: [
      {
        path: 'category',
        name: 'categoryList',
        component: () => import('@/views/Category/List'),
        meta: { title: '类别', icon: 'table' }
      },
      {
        path: 'category_Form',
        name: 'categoryList',
        component: () => import('@/views/Category/Form'),
        hidden: true,
        meta: { title: '类别', icon: 'table' }
      },
      {
        path: 'comment',
        name: 'commentList',
        component: () => import('@/views/Comment/List'),
        meta: { title: '评论', icon: 'table' }
      },
      {
        path: 'comment_Form',
        name: 'commentList',
        component: () => import('@/views/Comment/Form'),
        hidden: true,
        meta: { title: '评论', icon: 'table' }
      },
      {
        path: 'datasetfile',
        name: 'datasetfileList',
        component: () => import('@/views/DatasetFile/List'),
        meta: { title: '数据集_管理', icon: 'table' }
      },
      {
        path: 'datasetfile_form',
        name: 'datasetfileList',
        component: () => import('@/views/DatasetFile/Form'),
        hidden: true,
        meta: { title: '数据集_管理', icon: 'table' }
      },

    ]
  },

  /* 韦蓝清路由管理 */
  {
    path: '/wlq',
    component: Layout,
    redirect: '/wlq/list',
    name: '韦蓝清',
    meta: { title: '韦蓝清', icon: 'article' },
    children: [
      {
        path: 'Article',
        name: 'Article',
        component: () => import('@/views/Article/List'),
        meta: { title: '文章管理', icon: 'table' }
      },
      {
        path: 'Article_Form',
        name: 'Article',
        hidden: true,
        component: () => import('@/views/Article/Form'),
        meta: { title: '文章管理', icon: 'table' }
      },
      {
        path: 'BaseUser',
        name: 'BaseUser',
        component: () => import('@/views/BaseUser/List'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        path: 'BaseUser_Form',
        name: 'BaseUser',
        hidden: true,
        component: () => import('@/views/BaseUser/Form'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        path: 'UserRole',
        name: 'UserRole',
        component: () => import('@/views/UserRole/List'),
        meta: { title: '角色管理', icon: 'table' }
      },
      {
        path: 'UserRole_Form',
        name: 'UserRole',
        hidden: true,
        component: () => import('@/views/UserRole/Form'),
        meta: { title: '角色管理', icon: 'table' }
      },
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
